package servlet;

import service.OrderStatusService;
import service.OrdersService;
import service.impl.OrderStatusServiceImpl;
import service.impl.OrdersServiceImpl;
import urity.Page;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/OrdersServlet")
public class OrdersServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //设置编码
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=UTF-8");
        //定义session对象
        HttpSession session = request.getSession();
        //创建Writer对象
        PrintWriter out = response.getWriter();
        OrdersService service=new OrdersServiceImpl();

        int pageNo = Integer.parseInt(request.getParameter("pageNo"));
        int pageSize=10;

        //状态
        int state = Integer.parseInt(request.getParameter("state"));
        request.setAttribute("state",state);
        //订单号
        String orderNumder = request.getParameter("orderNumder");
        request.setAttribute("orderNumder",orderNumder);
        //查询信息
        Page page = service.selectLimit(pageNo, pageSize, orderNumder, state);
        request.setAttribute("page",page);
        //转发到
        request.getRequestDispatcher("order_list.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}